﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.burry.util.MapList" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bary</title>
<link rel="stylesheet" type="text/css" id="css" href="Resource/css/main.css">


<link rel="stylesheet" type="text/css" href="Resource/yui/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="Resource/yui/build/datatable/assets/skins/sam/datatable.css" />
<script type="text/javascript" src="Resource/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="Resource/yui/build/connection/connection-min.js"></script>
<script type="text/javascript" src="Resource/yui/build/json/json-min.js"></script>
<script type="text/javascript" src="Resource/yui/build/element/element-min.js"></script>
<script type="text/javascript" src="Resource/yui/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="Resource/yui/build/paginator/paginator.js"></script>
<script type="text/javascript" src="Resource/yui/build/datatable/datatable-min.js"></script>
<script type="text/javascript" src="Resource/yui/build/utilities/utilities.js"></script>


<body id="yahoo-com" class=" yui-skin-sam">
	<div id="framed">
  	<h2>内容管理</h2>
  </div>
  
  <div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<div id="demo">
    <div id="paging"></div>
    <div id="dt"></div>
    <br />
    <div id="function"><input type="button" value="修改" onclick="onSelectRowUpdate()" /> &nbsp; <input type="button" value="删除" onclick="onSelectRowDel()" /></div>
</div>


<script type="text/javascript">
var myDataTable = null;
YAHOO.util.Event.onDOMReady(function () {
    	
    	  var DataSource = YAHOO.util.DataSource,
        DataTable  = YAHOO.widget.DataTable,
        Paginator  = YAHOO.widget.Paginator;
        

       

        var myDataSource = new DataSource("listContentInit.do?");
        myDataSource.responseType = DataSource.TYPE_JSON;
        myDataSource.responseSchema = {
        		resultsList :"returnObj",  
            fields: ["id","title","type"],
            metaFields: {totalRecords: "totalRecords" }     
        };

		    var buildQueryString = function (state,dt) {
		        return "startIndex=" + state.pagination.recordOffset +
		               "&results=" + state.pagination.rowsPerPage;
		    };
		
		    var myPaginator = new Paginator({
		        containers         : ['paging'],
		        pageLinks          : 5,
		        rowsPerPage        : 15,
		        rowsPerPageOptions : [15,30,60],
		        template           : "<strong>{CurrentPageReport}</strong> {PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}",
		        firstPageLinkLabel:"首页",
            lastPageLinkLabel:"末页",
            nextPageLinkLabel:"下一页",
            previousPageLinkLabel:"上一页"

		    });
		
		    var myTableConfig = {
		        initialRequest         : 'startIndex=0&results=25',
		        generateRequest        : buildQueryString,
		        paginationEventHandler : DataTable.handleDataSourcePagination,
		        paginator              : myPaginator
		    };
		    
		    var myColumnDefs = [
            {key:"id",label:"编号"},
            {key:"title",label:"标题"},
            {key:"type",label:"类型"}
        ];

        myDataTable = new DataTable("dt", myColumnDefs, myDataSource, myTableConfig);
				myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow);   
	      myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);   
	      myDataTable.subscribe("rowClickEvent", myDataTable.onEventSelectRow);   
            

       
});

function onSelectRowUpdate(){
					var rows =  myDataTable.getSelectedRows();
					var record = myDataTable.getRecord(rows[0]);
					location.href = "updateContentInit.do?id="+record.getData("id");
}

function onSelectRowDel(){
					var rows =  myDataTable.getSelectedRows();
					var record = myDataTable.getRecord(rows[0]);
					location.href = "delContent.do?id="+record.getData("id");
}

</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

  </div>
</body>
</html>